package com.gxa.shop.servlet.discount;

import com.gxa.shop.bean.vo.DiscountOption;
import com.alibaba.fastjson.JSON;
import com.gxa.shop.commons.r.R;
import com.gxa.shop.service.discount.DiscountService;
import com.gxa.shop.service.discount.impl.DiscountServiceImpl;


import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

/**
 * com.gxa.shop.bean.servlet.discount
 * User: zjy
 * Date: 2024/12/19 21:52
 * motto:   逆水行舟不进则退
 * Description:
 * Version: V1.0
 */
@WebServlet(name = "DiscountAllListServlet",value = "/discount/findAllList")
public class DiscountAllListServlet extends HttpServlet {
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        DiscountService discountService=new DiscountServiceImpl();
        List<DiscountOption> list= discountService.findAllList();
        R r;
        r=list!=null?R.ok().addData("list",list):R.ok("没有分类信息");
        PrintWriter writer = resp.getWriter();
        String  result= JSON.toJSONString(r);
        System.out.println("FindAllListServlet:"+result);
        writer.write(result);
        writer.flush();
        writer.close();
    }}